package com.heaven.controller;

import com.heaven.pojo.Honor;
import com.heaven.service.HonorService;
import com.heaven.vo.PageResult;
import com.heaven.vo.SysResult;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/honor")
@CrossOrigin

public class HonorController {
    @Autowired
    private HonorService honorService;
    @GetMapping("/honorList")
    public SysResult honorList(PageResult pageResult){
        pageResult=honorService.honorList(pageResult);
        return SysResult.success(pageResult);
    }
    @GetMapping("/{id}")
    public SysResult honorById(@PathVariable Integer id){
        Honor honor=honorService.honorById(id);
        return SysResult.success(honor);
    }
    @PutMapping("/updataHonor")
    public SysResult updateHonor(@RequestBody Honor honor){
        honorService.updataHonor(honor);
        return SysResult.success();
    }
    @PostMapping("/addHonor")
    public SysResult addHonor(@RequestBody Honor honor){
        honorService.addHonor(honor);
        return SysResult.success();
    }
    @DeleteMapping("/delete/{id}")
    public SysResult deleteById(@PathVariable Integer id){
        honorService.deleteById(id);
        return SysResult.success();
    }
}
